package com.shanghaiyimu.yimiyangche.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shanghaiyimu.yimiyangche.R;
import com.shanghaiyimu.yimiyangche.bean.CarBeen;

import java.util.List;

/**
 * Author:ShangHaiYiMu
 * Time:2017/7/24   9:06
 * Description:THjiangjiaAdapter
 */

public class THjiangjiaAdapter extends BaseAdapter {
    private Context context;
    private List<CarBeen> datas;

    public THjiangjiaAdapter(Context context, List<CarBeen> datas) {
        this.context = context;
        this.datas = datas;
    }

    @Override
    public int getCount() {
        return datas!=null?datas.size():0;
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.car_thjiangjia_lv_item,parent,false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.name.setText(datas.get(position).getName());
        holder.price.setText(datas.get(position).getPrice()+"万");
        return convertView;
    }
    static class ViewHolder{
        private TextView name,price,yuanjia;
        public ViewHolder(View view) {
            name = (TextView) view.findViewById(R.id.name_jiangjia_item);
            price = (TextView) view.findViewById(R.id.jiage_jiangjia_item);
            yuanjia = (TextView) view.findViewById(R.id.yuanjia_jiangjia_item);
            // 中划线
            yuanjia.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG);
        }
    }
}
